/**
 * Created by F1231657 on 2018/1/4.
 */
// 1.引入vue和vue-router并赋值给相应的Vue和Router
import Vue from 'vue';
import Router from 'vue-router';

import home from '@/components/home/home.vue'
import roadIn from '@/components/home/roadIn.vue'
import roadOut from '@/components/home/roadOut.vue'
import newEnergy from '@/components/home/newEnergy.vue'
import shareBike from '@/components/home/shareBike.vue'
import keySearch from '@/components/home/keySearch.vue'
import smartSafe from '@/components/home/smartSafe.vue'

// 2.通过Vue的use方法注入Router
Vue.use(Router)
// 3.创建 router 实例，然后传 `routes` 配置
const router = new Router({
    // 指定路由选中时的样式类名
    linkActiveClass: 'active',
    hashbang: true, // 将路径格式化为#!开头
    history: true, // 启用HTML5 history模式，可以使用pushState和replaceState来管理记录
    /**
     * 4.@desc 路由配置配置具体的路径
     */
    routes: [
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/home',
            component: home
        },
        {
            path: '/roadIn',
            component: roadIn
        },
        {
            path:  `/roadOut`,
            component: () => import(/* webpackChunkName: "about" */ '../components/home/roadOut.vue')
        },
        {
            path: '/newEnergy',
            component: () => import(/* webpackChunkName: "about" */ '../components/home/newEnergy.vue')
        },
        {
            path: '/shareBike',
            component: shareBike
        },
        {
            path: '/keySearch',
            component: keySearch
        },
        {
            path: '/smartSafe',
            component: () => import(/* webpackChunkName: "about" */ '../components/home/smartSafe.vue')
        },
    ]
})
/**
 * @desc 全局监听路由变化
 */
// router.beforeEach((to, from, next) => {
//     store.dispatch('updateHistoryLength') // 变化时更新路由切换长度
//     next()
// })
// 5.导出路由
export default router
